import mitt from "mitt";
export type SelectionType = {
    anchor: number,
    focus: number
}
export class SelectionModel {
    textModel_: any;
    selection_:SelectionType | null;
    constructor(){
        this.selection_ = {anchor:0,focus:0}
    }
    getSelection() : SelectionType | null{
        return this.selection_ === null ? this.selection_ : {...this.selection_}
    }
    setSelection(selection: SelectionType){
        if(selection && this.selection_ && selection.anchor === this.selection_.anchor && selection.focus === this.selection_.focus) return
        this.selection_ = selection ? {...selection} : null
    }
    isCollapsed(){
        return this.selection_ && this.selection_.anchor === this.selection_.focus
    }
    isBackward () {
        return this.selection_ && this.selection_.anchor > this.selection_.focus
    }
}